<template>
<h1>员工列表练习</h1>
  <input type="text" placeholder="请输入员工姓名" v-model="empl.name">
  <input type="text" placeholder="请输入员工工资" v-model="empl.salary">
  <input type="text" placeholder="请输入员工岗位" v-model="empl.job">
 <button @click="add">点我添加</button>

  <table border="1px">
    <tr>
      <th>员工编号</th>
      <th>员工姓名</th>
      <th>员工工资</th>
      <th>员工岗位</th>
    </tr>
    <tr v-for="(item,index) in arr">
      <td>{{index+1}}</td>
      <td>{{item.name}}</td>
      <td>{{item.salary}}</td>
      <td>{{item.job}}</td>
    </tr>
  </table>
</template>

<script setup>
import {ref} from "vue";

const empl = ref([{name:'',salary: '',job:''}]);
const arr = ref([]);
const add=()=>{
  // if(empl.value.name.tirm()=='' || empl.value.salary.trim()==''||empl.value.job.trim()==''{
  //   alert('请输入完整信息');
  //   return;
  // }
  // console.log(empl.value);
  arr.value.push(empl.value);
  empl.value={name:'',salary:'',job:''}
}

</script>

<style scoped>

</style>